package com.example.bob.uicontrols;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {

    private ArrayAdapter<ListCellData> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        adapter = new ArrayAdapter<ListCellData>(this,android.R.layout.simple_list_item_1);
        setListAdapter(adapter);

        adapter.add(new ListCellData(this, "RadioGroup", new Intent(this, AtyUsingRadioGroup.class)));
        adapter.add(new ListCellData(this,"CheckBox",new Intent(this,AtyUsingCheckBox.class)));
        adapter.add(new ListCellData(this,"GridView",new Intent(this,AtyUsingGridView.class)));
        adapter.add(new ListCellData(this,"Notification",new Intent(this,AtyUsingNotification.class)));
        adapter.add(new ListCellData(this,"ScrollView",new Intent(this,AtyUsingScrollview.class)));
        adapter.add(new ListCellData(this,"ImageSwitcher",new Intent(this,AtyUsingImageSwitcher.class)));
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        ListCellData data = adapter.getItem(position);
        data.startActivity();
        super.onListItemClick(l, v, position, id);
    }
}
